@extends('admin.layouts.master')

@section('pagecss')
<link rel="stylesheet" type="text/css" href="/admin/assets/bootstrap-datepicker/css/datepicker.css" />
@endsection

@section('content')

<div class="row aw-list">
	<div class="col-lg-12">
		<section class="panel aw-content">
			<header class="panel-heading">临时价格调整</header>
			<div class="aw-mt20 overflow-hidden">
				<div class="col-sm-6 col-md-3 form-group overflow-hidden">
					<div class="col-xs-4 aw-p0 aw-list-input-title">店面：</div>
					<div class="col-xs-8 aw-p0">
						<select placeholder="请选择店面" id="store_id" name="store_id" v-model="form.store_id" :value="form.store_id" class="form-control">
							<option value="0">全部</option>
							<option v-for="(list,key) in list_store" :value="list.id">@{{list.store_name}}</option>
						</select>
					</div>
				</div>
				<div class="col-sm-6 col-md-3 form-group overflow-hidden">
					<div class="col-xs-4 aw-p0 aw-list-input-title">场地选择：</div>
					<div class="col-xs-8 aw-p0">
						<select placeholder="请选择店面" id="type" name="type" v-model="form.type" :value="form.type" class="form-control">
							<option value="0">全部</option>
							<option v-for="(list,key) in list_type" :value="list.id">@{{list.type_text}}</option>
						</select>
					</div>
				</div>
				<div class="col-sm-6 col-md-3 form-group overflow-hidden">
					<div class="col-xs-4 aw-p0 aw-list-input-title">设置时间：</div>
					<div class="col-xs-8 aw-p0">
						<input type="text" placeholder="请选择时间" id="day" name="day" v-model="form.day" :value="form.day" class="form-control">
					</div>
				</div>
				<div class="col-sm-6 col-md-3 form-group overflow-hidden">
					<a href="/admin/field/temporary-price?page_id=26" class="btn btn-gray"><i class="icon-refresh"></i> 重置</a>
				</div>
			</div>
			<div v-for="(list,key) in lists">
			<header class="panel-heading">@{{list.storefront_name}} @{{list.type_text}} @{{form.day}} <span v-if="list.program==1">规则一 07:00开始规则</span><span v-if="list.program==2">规则二 08:00开始规则</span></header>
			<ul class="aw-mt20 aw-overflow-hidden aw-field-time-list">
				<li class="col-sm-4 col-md-3 col-lg-2 aw-field-time-list-li aw-field-pirce-li" v-for="(li,key_li) in list.list">
					<div class="aw-field-time-li open">
						<p>@{{li.start_time}}-@{{li.end_time}}</p>
						<input type="text" class="form-control aw-text-center aw-mt10" v-model="li.price" :value="li.price">
						<a class="btn btn-gules btn-sm aw-mt10" v-on:click="Save_Price(key,key_li)">修改</a>
					</div>
				</li>
			</ul>
			</div>
			<div class="aw-text-center aw-list-null" v-if="lists_length==0">暂无场地</div>
		</section>
	</div>
</div>

@section('pagejs')
@parent

<!--日期插件-->
<script type="text/javascript" src="/admin/js/ga.js"></script>
<script type="text/javascript" src="/admin/assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>

<script type="text/javascript">
var MJS_URLArry=URLArry;
var Get_form={
	page_id:26,type:0,store_id:0,day:DateToday()
}
$.extend(Get_form,MJS_URLArry);
var AD_list={
	api:'/adminapi/field/price-temp-list',
	form_data:Get_form,
	tips:false,
}
var AD_list_store={
	api:'/adminapi/storefront/list',
	form_data:{page_num:100},
	tips:false,
}
var is_watch=1;
var Ajax_Vue_Fun_Store=function(vue_data){
	console.log('Data_Vue123')
	console.log(vue_data)
	var Data_Vue={
		lists:{},
		list_store:vue_data.list,
		list_type:Data_field_type_list,
		form:Get_form,
		lists_length:0,
	}
	vm=new Vue({
		el:'#Vue-Body',
		data:Data_Vue,
		methods:{
			Search_Price:function(){
				AD_list.form_data=vm.form;
				getData(AD_list,Ajax_Vue_Fun)
				URL_Make(vm.form)
			},Save_Price:function(key,key_li){
				console.log(key)
				console.log(this.lists)
				this.lists[key].list[key_li].day=this.form.day;
				this.lists[key].list[key_li].store_id=this.lists[key].list[key_li].storefront_id;
				var AD_price={
					api:'/adminapi/field/price-temp-save',
					form_data:this.lists[key].list[key_li],
					tips:'临时价格修改成功',
				}
				postData(AD_price)
			}
		},watch:{
	        'form.store_id':function(val,oldval){
	            console.log('门店改变')
	            console.log(val,oldval)
	            is_watch='store_id';
	            this.Search_Price()
	        },'form.type':function(val,oldval){
	            console.log('球场类型改变')
	            console.log(val,oldval)
	            if(is_watch!='store_id'){
	            	this.Search_Price()
	            }
	            is_watch='type';
	        },'form.day':function(val,oldval){
	            console.log('时间改变')
	            console.log(val,oldval)
	            if(is_watch=='store_id'){
	            	return;
	            }
	            if(is_watch=='type'){
	            	return;
	            }
	            if(is_watch==1){
	            	return;
	            }
	            this.Search_Price()
	        }
    	}	
	})
//	vm.form.store_id=$('#store_id option:eq(0)').val()
//	vm.form.type=$('#type option:eq(0)').val()
	$('#day').datepicker({
	    format:'yyyy-mm-dd',
	}).on('changeDate',Select_Date);
	function Select_Date(ev){
		var This_day=ev.date.getFullYear().toString() + "-"+ (ev.date.getMonth()+1).toString()+ "-"+ ev.date.getDate().toString()
		vm.form.day=This_day;
		$('#day').val(This_day)
		$('#day').blur()
    }
    vm.Search_Price()
}
var Ajax_Vue_Fun=function(vue_data){
	console.log(31313)
	console.log(vue_data)
	vm.lists=vue_data;
	vm.lists_length=vue_data.length;
	if(vm.lists_length == 0){
		vm.lists.type_text=$('#type').find("option:selected").text()
	}
	is_watch='';
}
getData(AD_list_store,Ajax_Vue_Fun_Store)
</script>
@endsection

@endsection

